<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	
</body>
<script>
	function Stack(){
		this.items=[];
		this.push=function(element){
			this.items.push(element);
		};
		this.pop=function(){
			return this.items.pop();
		};
		this.peek=function(){
			return this.items[this.items.length-1];
		};
		this.isEmpty=function(){
			return this.items.length==0;
		};
		this.size=function(){
			return this.items.length;
		};
		this.clear=function(){
			this.items=[];
		};
		this.print=function(){
			console.log(this.items.toString());
		}
	}

	//测试
	var stack=new Stack();
	console.log(stack.isEmpty());
	stack.push(5);
	stack.push(8);
	console.log(stack.peek());
	stack.push(11);
	console.log(stack.size());
	console.log(stack.isEmpty());

	stack.push(15);
	stack.pop();
	stack.pop();
	console.log(stack.size());
	stack.print();
</script>
</html>